package com.diligent.cloud.sfc.config;

import com.diligent.cloud.sfc.service.ObtainTokenService;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * statisticsQuartzConfig class
 *
 * @author xf107278
 * @date 2/13/2020
 */
@Configuration
public class StatisticsQuartzConfig {
    @Bean
    public JobDetail obtainTokenDetail() {
        return JobBuilder
                .newJob(ObtainTokenService.class)
                .withIdentity("obtainTokenQuartz")
                .storeDurably()
                .build();
    }



    @Bean("obtainTokenTrigger")
    public Trigger obtainTokenTrigger() {

        CronScheduleBuilder scheduleBuilder
                = CronScheduleBuilder.cronSchedule("0 0 0 */1 * ?");
        return TriggerBuilder
                .newTrigger()
                .forJob(obtainTokenDetail())
                .withIdentity("obtainTokenQuartz")
                .withSchedule(scheduleBuilder).build();
    }


}
